﻿using Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace RedisHelper.User
{
    public class Mail
    {
        /// <summary>
        /// 插入用户邮箱
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="mail"></param>
        /// <returns></returns>
        public bool InsertMail(string uid, string mail)
        {
            using (RedisHelper rh = new RedisHelper())
            {
                return rh.GetDatabase(2).HashSet(StaticConfigRidesName.UserMail_Hash(), uid.ToString(), mail);
            }
        }

        /// <summary>
        /// 获取用户邮箱
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public string SelectMail(string uid)
        {
            using (RedisHelper rh = new RedisHelper())
            {
                var data = rh.GetDatabase(2).HashGet(StaticConfigRidesName.UserMail_Hash(), uid.ToString());
                if (data.IsNull)
                    return null;
                return data;
            }
        }
    }
}